package com.flyduck.mall.oms.remote.service.impl;

import com.flyduck.mall.common.core.utils.BeanUtils;
import com.flyduck.mall.oms.remote.service.RemoteOrderItemService;
import com.flyduck.mall.oms.domain.OmsOrderItem;
import com.flyduck.mall.oms.mapper.OmsOrderItemMapper;
import com.flyduck.mall.oms.api.vo.RemoteOrderItemRespVO;
import com.flyduck.mall.oms.api.vo.RemoteOrderItemUpdateReqVO;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 * RemoteOrderItemServiceImpl
 * </p>
 *
 * @author flyduck
 * @since 2024-07-23
 */
@DubboService
public class RemoteOrderItemServiceImpl implements RemoteOrderItemService {

    @Resource
    private OmsOrderItemMapper omsOrderItemMapper;

    @Override
    public RemoteOrderItemRespVO getOrderItemById(Long id) {
        OmsOrderItem omsOrderItem = omsOrderItemMapper.selectById(id);
        return BeanUtils.toBean(omsOrderItem, RemoteOrderItemRespVO.class);
    }

    @Override
    public void updateOrderItem(RemoteOrderItemUpdateReqVO remoteOrderItemUpdateReqVO) {
        OmsOrderItem omsOrderItem = BeanUtils.toBean(remoteOrderItemUpdateReqVO, OmsOrderItem.class);
        omsOrderItemMapper.updateById(omsOrderItem);
    }
}
